home *** CD-ROM | disk | FTP | other *** search
- // state components:
-
- // cashonhand: integer
- // inc: map(string,integer)
- // exp: map(string,integer)
-
- receive(amount,source) {cashonhand=cashonhand+amount;
- inc[source]=inc[source,0]+amount;
- return "ok";};
- spend(amount,reason) {if(amount>cashonhand) return "Insufficient funds";
- cashonhand=cashonhand-amount;
- exp[reason]=exp[reason,0]+amount;
- return "ok";};
- totalrec(source) {return inc[source,0];};
- totalspent(reason) {return exp[reason,0];};
- cashonhand=100;
- end